package com.changpei.search.pojo;

import com.alibaba.fastjson.JSONObject;
import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 *
 * <p>Title : CommentIndex</p>
 * <p>Description : CommentIndex构建</p>
 * @author weibiao
 */
@Document(indexName = "comment", type = "comment")
@Data
public class CommentIndex implements Serializable {

    /** serialVersionUID*/
    private static final long serialVersionUID = -1L;

    /**
     * 主键
     */
    @Id
    @Field(type = FieldType.Long)
    private Long id;

    /**
     * 用户ID
     */
    @Field(type = FieldType.Long)
    private Long userId;

    /**
     * 用户头像
     */
    @Field(type = FieldType.Text)
    private String avatarUrl;

    /**
     * 用户昵称
     */
    @Field(type = FieldType.Text)
    private String nickName;

    /**
     * 父级评论ID(为0则是一级评论,不为0则是回复)
     */
    @Field(type = FieldType.Long)
    private Long parentCommentId;

    /**
     * 评论内容
     */
    @Field(type = FieldType.Text, analyzer = "ik_max_word")
    private String content;

    /**
     * 回复对象id
     */
    @Field(type = FieldType.Long)
    private Long replyId;

    /**
     * 内容ID
     */
    @Field(type = FieldType.Long)
    private Long contentId;

    /**
     * 点赞数量
     */
    @Field(type = FieldType.Long)
    private Long praiseNum;

    /**
     * 回复数量
     */
    @Field(type = FieldType.Long)
    private Long replyNum;

    /**
     * 创建时间
     */
    @Field(type = FieldType.Date)
    private Date createTime;

    /**
     * 回复用户信息
     */
    @Field(type = FieldType.Nested)
    private JSONObject reply;

    /**
     * 评论回复子集
     */
    @Field(type = FieldType.Nested)
    private List<JSONObject> children;

}
